﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveCamera456 : MonoBehaviour {

	public float sensitivityMouse = -0.02f;
	public float rate = -0.1f;

	private Transform transform_;
	private Camera camera_;

	private void Start() {
		transform_ = GetComponent<Transform>();
		camera_ = GetComponent<Camera>();
	}

	void Update() {

		//鼠标左键按住拖动控制移动
		if (Input.GetMouseButton(0)) {
			float t = sensitivityMouse * transform_.position.z;
			transform_.Translate(-Input.GetAxis("Mouse X") * t, -Input.GetAxis("Mouse Y") * t, 0);
		}
		//鼠标滚轮控制摄像机前进/后退
		if (Input.GetAxis("Mouse ScrollWheel") != 0) {
			if (Input.GetAxis("Mouse ScrollWheel") > 0) {
				camera_.orthographicSize *= 1 + rate;
			}
			else {
				camera_.orthographicSize *= 1 - rate;
			}
		}
	}

}
